﻿namespace Pp.Domain.Mappings
{
    using Model;

    public sealed class ProjectMap : EntityMap<Project>
    {
        public ProjectMap()
        {
            Map(d => d.Description).Length(MAX_LENGTH);
            Map(d => d.Name);
            Map(d => d.ProjectCosting);
            References(d => d.Category, "CategoryId").Not.Nullable().LazyLoad();
            HasMany(d => d.Likes).KeyColumn("ProjectId").LazyLoad().Cascade.AllDeleteOrphan().LazyLoad();
            HasMany(d => d.Angels).KeyColumn("ProjectId").LazyLoad().Cascade.AllDeleteOrphan().LazyLoad();
            HasMany(d => d.Comments).KeyColumn("ProjectId").LazyLoad().Cascade.AllDeleteOrphan().LazyLoad();
            HasMany(d => d.AngelRequests).KeyColumn("ProjectId").LazyLoad().Cascade.AllDeleteOrphan().LazyLoad();
            HasMany(d => d.Follows).KeyColumn("ProjectId").LazyLoad().Cascade.AllDeleteOrphan().LazyLoad();
            References(d => d.User, "UserId").LazyLoad();
            Map(d => d.SignatureCollect);
            Map(d => d.AllowAngelRequest);
            Map(d => d.SmallDescription);
        }
    }
}